<?php				
	interface price_class_info
	{		
		function getPriceList($CATName,$AssName,$OrderBy);
	}
	
	class price_class implements price_class_info
	{
		function price_class()
		{
			@session_start(); 
			require_once('../../lib/'.'BaseDir.inc.htm');
			require_once(EIU_LIB.'DBCommon.class.htm');					
		}
		
		function getPriceList($CATName,$AssName,$OrderBy)
		{
			$oDB = new DBCommon();
			$conn =  $oDB->stl_openConn();
			
			
			$q = "
				SELECT 
						A.AssName,A.CATCode,A.Unit,A.CATName,
						B.SellDate, IFNULL(B.Price,0) AS Price,B.PriceHistory,
						B.CreateDate,B.LastUpdate,B.ModifiedBy
				FROM 
					( 
						SELECT asset_tbl.`AssName`,asset_tbl.`CATCode`,asset_tbl.`Unit`, category_tbl.CATName 
						FROM `asset_tbl` LEFT JOIN category_tbl ON category_tbl.CATCODE = asset_tbl.CATCode 
						WHERE `asset_tbl`.`isDeleted` = 0 
						GROUP BY asset_tbl.`AssName`,asset_tbl.`CATCode`,asset_tbl.`Unit` 
					) AS A LEFT JOIN 
						`price_tbl` AS B ON 
							`A`.`AssName` = `B`.`AssName` AND 
							`A`.`CATCode` = B.`CATCode` AND 
							A.`Unit` = B.Unit 
				WHERE A.`AssName` LIKE '%".$AssName."%' AND `CATName` LIKE '%".$CATName."%' 
				ORDER BY `".$OrderBy."` ASC

			";
			
			//echo $q; exit();
			
			$rs = $oDB->stl_db_select($q, $conn);
			
			$oDB->stl_closeConn($conn);
			
			if($rs)	return $rs;
			else return false;		
		}	
	}
?>